package com.xdcplus.web.controller.task;

import com.xdcplus.exceptions.domain.ResponseVO;
import com.xdcplus.mom.controller.AbstractController;
import com.xdcplus.pager.vo.PageVO;
import com.xdcplus.web.common.pojo.dto.task.JobTaskSwysFilterDTO;
import com.xdcplus.web.common.pojo.vo.task.JobTaskSwysVO;
import com.xdcplus.web.service.task.JobTaskSwysService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Validation;


/**
 * 丝印岗位任务(JobTaskSwys)表服务控制层
 *
 * @author Richard.Li
 * @since 2024-06-19 09:11:05
 */
@Api(tags = "丝印岗位任务(JobTaskSwys)") 
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("jobTaskSwys")
public class JobTaskSwysController extends AbstractController {

    @Autowired
    private JobTaskSwysService jobTaskSwysService;

    @ApiOperation("查询丝印岗位任务")
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<PageVO<JobTaskSwysVO>> findJobTaskSwys(JobTaskSwysFilterDTO jobTaskSwysFilterDTO) {

        // 检查并处理 alarmMsg 中的转义双引号
        if (jobTaskSwysFilterDTO.getAlarmMsg() != null) {
            jobTaskSwysFilterDTO.setAlarmMsg(jobTaskSwysFilterDTO.getAlarmMsg().replace("\\\"", "\""));
        }

        log.info("findJobTaskSwys {}", jobTaskSwysFilterDTO);

        Validation.buildDefaultValidatorFactory().getValidator().validate(jobTaskSwysFilterDTO);

        return ResponseVO.success(jobTaskSwysService.queryJobTaskSwys(jobTaskSwysFilterDTO));
    }

}
